<div class="users form">

<div class="clearfix text-right">
	<a target="_blank" href="{{$this->Html->url('/admin/ace/editors/index?app=manage&theme=default&file=Layouts/Emails/html/default.html')}}" class="btn btn-primary">
		{{__('Edit Email Layout Template File')}}
	</a>
	<a target="_blank" href="{{$this->Html->url('/admin/ace/editors/index?app=manage&theme=default&file=/Emails/html/content.html')}}" class="btn btn-primary">
		{{__('Edit Email Content Template File')}}
	</a>
</div>
	
<?php 
echo $this->MForm->create($current_model,array(
	'url' => array('action' => 'email'),
));
?>
<?php print_r($resultinfo); ?>
<fieldset>
            
    <div class="tab-content">
                <div id="article-main" class="tab-pane active">
                	 <?php
                	 	echo $this->MForm->input('email',array('type'=>'text', 'size'=>'80','label'=> __d('admin','Email To'),));
				        echo $this->MForm->input('name',array('size'=>'80','label'=> __d('admin','Email Title')));

						 echo $this->MForm->input('template_id',array('type'=>'select','label'=> __d('admin','Email Template'),'options'=>$email_templates));
				     ?>
				     <div class="clearfix"></div>
				  <?php				
					echo $this->MForm->ckeditor('content',array('label' =>  __d('admin','Email Content')));
				  ?>
				  
				  <div class="form-group has-success form-inline">
				  		<label for="ToolName" class="col-sm-2 control-label">{{ __d('admin','Save Template')}}</label>
				  		<div class="col-sm-10 controls text">
					  		 <?php
							  echo $this->MForm->input('save_type',array('type'=>'radio','size'=>'80','div'=>false,'legend'=>false,'label'=>array('class'=>'radio-inline'),'default'=>0,'options'=>array('0'=>__d('admin','Don\'t Save'),'1'=>__d('admin','Save New Template'),'2'=>__d('admin','Update Template'))));
							?>
				  		</div>
				  </div>
				  
				 
				  
				  
                </div>                	
    </div>
 
    
    <div class="form-group">
    	<label class="col-sm-2 control-label"></label>
    	<div class="col-sm-10 controls"><?php echo $this->MForm->submit(__d('admin','Submit'),array('id'=>'btnsubmit')); ?></div>
    </div>
</fieldset>
	{{$this->MForm->end()}}
</div>

<script>
$(function(){
	$('#ToolTemplateId').change(function(){
		if(this.value!=0){
			$(this).after('<div id="template-ajax-loading"><img src="{{$this->Html->url("/img/ajax/wheel_throbber.gif")}}">{{__d('admin','Loading...')}}</div>')
			ajaxAction('/admin/templates/view/'+this.value,null,null,function(data){
				ckeditors['ToolContent'].setData(data.content);
				$('#template-ajax-loading').remove();
			});
		}
		else{
			ckeditors['ToolContent'].setData("");
		}		
	});
})
</script>

